﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HotelMatchUtility.Entity;
using HotelMatchUtility.Utility;

namespace HotelMatchUtility.Comparer
{
    public class Impl_NameAddressComparer : HotelCompareBase, ICompareCondition
    {
        //最低需要比较的 英文单词数
        private int lowestWordNum;
        //大于最低字符数时，需要达到的酒店名精确率0-1
        private double nameAccurency;
        //大于最低字符数时，需要达到的地址精确率0-1
        private double addressAccurency;

        public Impl_NameAddressComparer(int lowestWordNum, double nameAccurency, double addressAccurency)
        {
            this.lowestWordNum = lowestWordNum;
            this.nameAccurency = nameAccurency;
            this.addressAccurency = addressAccurency;
            ConditionName = string.Format("【精确】[酒店名]{0}匹配 且[地址]{1}匹配", nameAccurency.ToString("p"), addressAccurency.ToString("p"));
            IsExactCondition = true;
            IsExclusiveCondition = true;
            TargetIsContinue = true;
        }

        public override bool DoCompare(HotelEntity hotelTarget, HotelEntity hotelToCompare)
        {
            return
                CommonUtility.CompareTwoStringSimilary(hotelTarget.GetFormatName(), hotelToCompare.GetFormatName(), nameAccurency)
                && CommonUtility.CompareTwoStringSimilary(hotelTarget.GetFormatAddress(), hotelToCompare.GetFormatAddress(), addressAccurency);
        }
    }
}
